//
//  SWMyOperatersTableViewController.m
//  sc-cyan-ios
//
//  Created by lvjian01 on 2017/12/26.
//  Copyright © 2017年 greenbuilding. All rights reserved.
//

#import "SWMyOperatersTableViewController.h"
#import "SWMyOperatersTableViewCell.h"
#import "SWSearchBar.h"

@interface SWMyOperatersTableViewController ()

@property (nonatomic, strong) SWSearchBar *searchBar;

@end

@implementation SWMyOperatersTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (SWSearchBar *)searchBar{
    if (!_searchBar) {
        _searchBar = [[SWSearchBar alloc] initWithFrame:CGRectMake(18, 10, Main_Screen_Width - 36, 35) searchBarStyle:SWSearchBarStyleDefault];
        _searchBar.placeholder = @"搜索你的操作人员";
        _searchBar.placeholderColor = UIColorFromRGB(0x999999);
//        _searchBar.barBackgroudColor = [UIColor redColor];
        _searchBar.textColor = [UIColor gb_textColor_4D4D4D];
        _searchBar.tintColor = [UIColor gb_textColor_4D4D4D];
        _searchBar.placeholderFontSize = 13;
        _searchBar.textFontSize = 13;
        _searchBar.textBordStyle = SWTextBorderStyleRoundRect;
        
//        [_searchBar setSearchBarBordeWidth:0 bordColor:[UIColor clearColor] bordRadius:15];
        _searchBar.layer.cornerRadius = 17.5;
        _searchBar.backgroundColor = [UIColor whiteColor];
        [_searchBar searchBarTextSearchTextBlock:^(NSString *searchText) {
            NSLog(@"%@",searchText);
        }];
        
    }
    return _searchBar;
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SWMyOperatersTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SWMyOperatersTableViewCell class]) forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 55;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.0001;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 55)];
    headerView.backgroundColor = UIColorFromRGB(0xF7F7F7);
    [headerView addSubview:self.searchBar];
//    [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(headerView).with.insets(UIEdgeInsetsMake(10, 18, 10, 18));
//    }];
//    
    
    return headerView;
}

#pragma mark -- table view delegate


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
